<template>
  <div class="main-nav">
    <nav-bar class="home-nav">
      <div class="left" slot="left" @click="goBack"><van-icon name="arrow-left" size="24" /></div>
      <div slot="center">设备数据</div>
    </nav-bar>
    <div v-if="!isNoData">
      <div class="" style="background-color: #ffffff;">
        <div class="base_select">
          <van-dropdown-menu >
            <van-dropdown-item v-model="base_id" :options="baseList" @change="getChangeList" :style="{'justify-content':'end'}"/>
          </van-dropdown-menu>
        </div>
      </div>
      <equip-view :batch="equipList"></equip-view>
    </div>
    <div v-else>
      <no-data></no-data>
    </div>
  </div>
</template>

<script>
  import NavBar from "@/components/common/navbar/NavBar";
  import noData from "@/components/content/nodata";
  import equipView from ".././childComps/equipView";

  export default {
    name: "index",
    components:{
      NavBar,
      noData,
      equipView
    },

    data(){
      return {
        isNoData:false,
        cur_index: '',
        cur_prod_index: '',
        base_id: 0,
        showPicker: false,
        name: '',
        equipList: [],
        baseList: [],
        page:1,
        limit:10,
        loading: false,
        finished: false,
      }
    },

    created() {
      this.getEquipList()
    },
    methods: {
      goBack(){
        this.$router.go(-1);
      },
      getEquipList() {
        let that = this;
        that.$http.get('/api/monitorApi/check_equip', {}, r => {
          that.baseList = JSON.parse(r.data.baseList);
          that.equipList = r.data.equip_list;
          if(r.data.equip_list.length==0){
            that.isNoData=true
          }
        })
      },
      onLoad() {
        let that = this;
        that.page++;
        that.$http.get('/api/monitorApi/check_equip', {page:that.page,limit:that.limit}, r => {
          that.historyList = that.historyList.concat(r.data);
          // 加载状态结束
          this.loading = false;
          // 数据全部加载完成
          if (r.data.length == 0) {
            this.finished = true;
          }
        })
      },
      getChangeList(param){
        let that = this;
        that.$http.get('/api/monitorApi/check_equip', {base_id:param}, r => {
          that.equipList = r.data.equip_list;
        })
      },
      getBatch() {

      },
      onConfirm() {
        this.showPicker = false;
      },
      onSelectAll() {

      },
    }
  }
</script>

<style scoped>


</style>
